import tkinter as tk
from tkinter import ttk

def on_combobox_selected(event):
    selected_value = combobox.get()
    print(f"Selected internal value: {selected_value}")
if __name__ == '__main__':



    root = tk.Tk()

    # 定义选项字典，键为实际值，值为显示值
    options = {'A1': 'Option A', 'B2': 'Option B', 'C3': 'Option C'}

    # 创建Combobox
    combobox = ttk.Combobox(root, values=list(options.values()))

    # 设置初始选中值对应的内部值
    combobox.set('A1')

    # 绑定事件处理函数
    combobox.bind('<<ComboboxSelected>>', on_combobox_selected)

    combobox.pack()

    root.mainloop()